package com.zhy.learning.demo.cal;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.metadata.BaseRowModel;
import com.alibaba.excel.metadata.Sheet;
import com.alibaba.fastjson.JSONObject;
import com.zhy.learning.demo.util.ExcelUtil;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhy
 * @date 2020/3/17 2:29 下午
 * @description 还款计划实体类
 */
@Data
public class RepaymentPlan extends BaseRowModel {

    /**
     * 剩余本金
     */
    @ExcelProperty(value = "剩余本金", index = 0)
    private double remainPrincipal;
    /**
     * 月供
     */
    @ExcelProperty(value = "月供", index = 1)
    private double monthPay;
    /**
     * 本期还款利息
     */
    @ExcelProperty(value = "本期还款利息", index = 2)
    private double monthInterest;
    /**
     * 本期还款本金
     */
    @ExcelProperty(value = "本期还款本金", index = 3)
    private double monthPrincipal;

    public static void main(String[] args) {
        Sheet readSheet = new Sheet(1, 0);
        readSheet.setSheetName("Sheet1");
        readSheet.setStartRow(0);
        List<Object> objs = ExcelUtil.readLessThan1000RowBySheet("/Users/qudian/zhy/age.xlsx", readSheet);
        System.out.println(JSONObject.toJSONString(objs));
        List<String> list = null;
        List<String> data = new ArrayList<>();
        String age = null;
        String str = null;
        for (Object obj : objs) {
//            System.out.println("obj=" + obj);
            list = (ArrayList<String>) obj;
//            System.out.println("转换后=" + list.get(0));
            str = list.get(0);
            age = "19" + str.substring(0, 2) + "-" + str.substring(3, 5);
//            System.out.println(age);
            data.add(age);
        }

    }
}
